package com.juzipi.demo.handler;

import com.juzipi.demo.constant.ResultCode;
import com.juzipi.demo.tools.json.ResultTool;
import com.juzipi.demo.utils.json.JsonAuthentication;
import com.juzipi.demo.utils.json.Result;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 注销成功
 */

public class MyLogoutSuccessHandler extends JsonAuthentication implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        Result result = ResultTool.successCustomize(ResultCode.LOGOUT_SUCCESSFULLY, null);

        this.WriteJson(httpServletRequest,httpServletResponse,result);
    }
}
